#!/usr/bin/env bash

set -ve

export LFS='/mnt/lfs'
export SCRIPT_PATH=$(cd $(dirname $0); pwd)
export ROOT_PATH=$(dirname $SCRIPT_PATH)

echo LFS: $LFS
echo SCRIPT_PATH: $SCRIPT_PATH
echo ROOT_PATH: $ROOT_PATH

# 创建挂载 ROOT 分区
sudo mkdir -pv /mnt/lfs
sudo mount /dev/sda1 /mnt/lfs

# sudo usermod -a -G vboxsf ubuntu
# sudo newgrp vboxsf
# sudo newgrp ubuntu

export LANG=en_US.UTF-8
# export LANG=zh_CN.UTF-8

bash $SCRIPT_PATH/002.prepare.sh

bash $SCRIPT_PATH/001.version-check.sh
bash $SCRIPT_PATH/002.prepare.sh
bash $SCRIPT_PATH/003.packages.sh
bash $SCRIPT_PATH/004.user-env.sh
python3 $ROOT_PATH/run_shell.py -c "su lfs -c 'bash $SCRIPT_PATH/005.build.sh'" -o "$SCRIPT_PATH/005.build.log"

ROOT=/media/sf_play-lfs python3 $ROOT/run_shell.py -c "sudo su lfs -c 'bash $ROOT/scripts/005.build.002.gcc.sh'" -o "/tmp/005.build.log"
